
function showToast(title, mask = true){
  wx.showToast({
    title: title,
    icon: 'none',
    mask: mask,
    duration: 2000,
  })
}

function showSuccess(title, mask = true){
  wx.showToast({
    title: title,
    icon: 'success',
    mask: mask,
    duration: 2000,
  })
}

function showIcon(title,img, mask = true) {
 wx.showToast({
   title: title,
   icon: 'success',
   image: img,
   mask: mask,
   duration: 2000,
 })
}

function showLoading(title = '加载中'){
   wx.showLoading({
     title: title,
     mask: true,
   })
}

function hideLoading(){
   wx.hideLoading();
}

function showModal(title,content, confirm, cancel){
   wx.showModal({
     title: title,
     content: content,
     success: function (res) {
       if (res.confirm) {
          confirm();
       } else if (res.cancel) {
          cancel();
       }
     }
   })
}


module.exports = {
 showToast: showToast,
 showSuccess: showSuccess,
 showLoading: showLoading,
 showIcon: showIcon,
 hideLoading: hideLoading,
 showModal: showModal,
}